var a = getApp();

Page({
    data: {
        data: "",
        teamId: ""
    },
    loadData: function() {
        var t = this;
        a.network.post({
            url: a.url.listEchelon,
            params: {
                teamId: t.data.teamId
            },
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(o) {
                1 == o.data.result ? t.setData({
                    data: o.data.data.echelons
                }) : a.util.showToast(o.data.message);
            },
            fail: function() {
                a.util.showToast("加载失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    upData: function(t) {
        var o = this;
        a.network.post({
            url: a.url.upEchelon,
            params: {
                teamId: o.data.teamId,
                id: t
            },
            before: function() {
                wx.showNavigationBarLoading(), wx.showLoading({
                    title: "正在提交"
                });
            },
            success: function(t) {
                wx.hideLoading(), 1 == t.data.result ? o.loadData() : a.util.showToast(t.data.message);
            },
            fail: function() {
                wx.hideLoading(), a.util.showToast("操作失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    delData: function(t) {
        var o = this;
        a.network.post({
            url: a.url.deleteEchelon,
            params: {
                teamId: o.data.teamId,
                id: t
            },
            before: function() {
                wx.showNavigationBarLoading(), wx.showLoading({
                    title: "正在删除"
                });
            },
            success: function(t) {
                wx.hideLoading(), 1 == t.data.result ? o.loadData() : a.util.showToast(t.data.message);
            },
            fail: function() {
                wx.hideLoading(), a.util.showToast("操作失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    clickUp: function(a) {
        var t = a.currentTarget.dataset.echelonid;
        this.upData(t);
    },
    clickDel: function(a) {
        var t = a.currentTarget.dataset.name, o = this;
        wx.showModal({
            title: "提示",
            content: "确定删除梯队" + t + "?",
            success: function(t) {
                if (t.confirm) {
                    var e = a.currentTarget.dataset.echelonid;
                    o.delData(e);
                } else t.cancel && console.log("用户点击取消");
            }
        });
    },
    clickConfirm: function(a) {
        wx.navigateTo({
            url: "teamMemberAddTeam/teamMemberAddTeam?teamId=" + this.data.teamId + "&level=" + this.data.data.length
        });
    },
    onLoad: function(a) {
        this.setData({
            teamId: a.teamId
        });
    },
    onReady: function() {},
    onShow: function() {
        this.loadData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});